//===============================================================================
// Microsoft patterns & practices Enterprise Library Contribution
// Query Application Block
//===============================================================================

using System;
using System.ComponentModel;
using EntLibContrib.Query.Properties;

namespace EntLibContrib.Query.Configuration.Design
{
  /// <summary>
	/// Represents a <see cref="NameValueParameterData"/> configuration element.
  /// </summary>
  public class NameValueParameterNode : ParameterNode
	{
		#region Properties
		/// <summary>
		/// Gets the <see cref="NameValueParameterData"/> this node represents.
		/// </summary>
		/// <value>
		/// The <see cref="NameValueParameterData"/> this node represents.
		/// </value>
		[ReadOnly(true)]
		public override ParameterData ParameterData
		{
			get { return new NameValueParameterData(Name); }
		}
		#endregion

		#region Construction
		/// <summary>
		/// Initialize a new instance of the <see cref="ParameterNode"/> class.
		/// </summary>
		public NameValueParameterNode()
			: this(new NameValueParameterData(InternalResources.DefaultNameValueParameterNodeName))
    {
		}

		/// <summary>
		/// Initialize a new instance of the <see cref="NameValueParameterNode"/> class with an <see cref="NameValueParameterData"/> instance.
		/// </summary>
		/// <param name="nameValueParameterData">An <see cref="NameValueParameterData"/> instance</param>
		public NameValueParameterNode(NameValueParameterData nameValueParameterData)
    {
			if (nameValueParameterData == null)
				throw new ArgumentNullException("nameValueParameterData");

			Rename(nameValueParameterData.Name);
		}
		#endregion

		#region Public Methods
		/// <summary>
		/// Clones this instance.
		/// </summary>
		/// <returns></returns>
		public override ParameterNode Clone()
		{
			return new NameValueParameterNode((NameValueParameterData)this.ParameterData);
		}
		#endregion
	}
}